<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ attribute name="value" required="true" rtexprvalue="true"%>
<%@ attribute name="label" required="true" rtexprvalue="true"%>
<%@ attribute name="name" rtexprvalue="true"%>
<%@ attribute name="help" rtexprvalue="true"%>
<%@ attribute name="required" rtexprvalue="true"%>
<%@ attribute name="single" rtexprvalue="true"%>
<%@ attribute name="height" rtexprvalue="true"%>
<%@ attribute name="onchange" rtexprvalue="true"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<c:if test="${required==null}">
	<c:set var="required" value="false" />
</c:if>

<c:choose>
	<c:when test="${single==null}">
		<c:set var="single" value="1" />
	</c:when>
	<c:when test="${single==1}">
		<c:set var="single" value="3" />
	</c:when>
	<c:otherwise>
		<c:set var="single" value="1" />
	</c:otherwise>
</c:choose>

<c:if test="${height==null}">
<c:set value="230" var="height"/>
</c:if>
<c:set var="base" value="${pageContext.request.contextPath}/service/contentAction" scope="request"/>
<script src="${base}/resource/fckeditor/fckeditor.js" type="text/javascript"></script>
<c:set var="appBase" value="/content"/>

<c:set var="editorBasePath" value="${base}/resource/fckeditor/" />
<c:set var="filemanager"
	value="${editorBasePath}editor/filemanager/browser/default/browser.html" />

<th><c:if test="${required}">
	<label class="requireField">*</label>
</c:if> <label>${label}:</label></th>

<td colspan="${single}">

<script type="text/javascript">

var editor = new FCKeditor("${name}");
editor.BasePath = "${editorBasePath}";

editor.Config["CustomConfigurationsPath"]="${editorBasePath}myconfig.js";

editor.Config["LinkBrowser"] = false ;
editor.Config["ImageBrowser"] = false ;
editor.Config["FlashBrowser"] = false ;
editor.Config["MediaBrowser"] = false ;

editor.Config["LinkBrowserURL"] = "${filemanager}?Connector=${base}/fck/connector.do" ;
editor.Config["ImageBrowserURL"] = "${filemanager}?Type=Image&Connector=${base}${appBase}/fck/connector.do" ;
editor.Config["FlashBrowserURL"] = "${filemanager}?Type=Flash&Connector=${base}${appBase}/fck/connector.do" ;
editor.Config["MediaBrowserURL"] = "${filemanager}?Type=Media&Connector=${base}${appBase}/fck/connector.do" ;

editor.Config["LinkUpload"] = true ;
editor.Config["ImageUpload"] = true ;
editor.Config["FlashUpload"] = true ;
editor.Config["MediaUpload"] = true ;

editor.Config["LinkUploadURL"] = "${base}${appBase}/upload.do" ;
editor.Config["ImageUploadURL"] = "${base}${appBase}/upload.do?Type=Image" ;
editor.Config["FlashUploadURL"] = "${base}${appBase}/upload.do?Type=Flash" ;
editor.Config["MediaUploadURL"] = "${base}${appBase}/upload.do?Type=Media" ;

editor.ToolbarSet="My";
editor.Height=${height};
editor.Value="${fn:replace(fn:replace(value,'\"','\\"'),'/n/r','')}";
editor.Create();

function FCKeditor_OnComplete( editorInstance )
{
    editorInstance.Events.AttachEvent('OnSelectionChange', DoSomething) ;
}

function DoSomething( editorInstance )
{
	if(editorInstance.IsDirty())
  	  ${onchange};
}


</script>
${help}
</td>
